﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using l1cs.server.datatables;
using l1cs.server.model;

namespace l1cs.server
{
    class UbTimeController
    {
        private static Logger _log = Logger.getLogger( typeof( UbTimeController ).FullName );

        private static UbTimeController _instance;

        public static UbTimeController getInstance()
        {
            if ( _instance == null )
            {
                _instance = new UbTimeController();
            }
            return _instance;
        }

        /// <summary>
        /// UB開始時間をチェックするスレッド関数
        /// </summary>
        /// <param name="state"></param>
        public void threadSub( object state )
        {
            while ( true )
            {
                // UB開始時間をチェック
                foreach ( L1UltimateBattle ub in UBTable.getInstance().getAllUb() )
                {
                    if ( ub.checkUbTime() && !ub.isActive() )
                    {
                        ub.start(); // UB開始
                    }
                }
                Thread.Sleep( 15000 );
            }
        }
    }
}
